  var app = getApp();
  var com = require('../../common.js');
  Page({
    data: {
      info: {},
      information: {}
    },
    onLoad: function(options) {
      var _this = this
      console.log(options)
      _this.setData({
        information: JSON.parse(options.info)
      })
      if (wx.getStorageSync('upData')) {
        _this.setData({
          upData: true
        })
      } else {
        _this.setData({
          upData: false
        })
      }
      console.log(_this.data.information)
      _this.onShopStatus()
    },
    onShowSli() {
      wx.navigateTo({
        url: '/pages/shiliPage/shiliPage',
      })
    },
    //获取信息
    onShopStatus() {
      var _this = this,
        i = _this.data.information
      com.link(app.link.onShopCentent + wx.getStorageSync('store') + '.st', {}, function(res) {
        console.log(res)
        res.data.data.address = i.address
        res.data.data.title = i.title
        _this.setData({
          info: res.data.data
        })
        console.log(res.data.data)
      }, "GET")
    },
    //上传照片方法
    onShowFile(e) {
      var _this = this,
        id = e.currentTarget.id,
        list = _this.data.info
      wx.chooseImage({
        count: 1,
        success: function(res) {
          console.log(res)
          wx.uploadFile({
            url: app.link.temporary, //为后端上传代码方法
            filePath: res.tempFilePaths[0],
            name: 'file',
            formData: {
              file: res.tempFilePaths[0]
            },
            success: function(res) {
              let img = JSON.parse(res.data)
              console.log(img)
              if (id == 1) {
                list.idcode_positive = img.response.file.name
                list.idcode_positive_url = img.response.file.http
              } else if (id == 2) {
                list.idcode_other = img.response.file.name
                list.idcode_other_url = img.response.file.http
              } else if (id == 3) {
                list.store_environmental = img.response.file.name
                list.store_environmental_url = img.response.file.http
              } else if (id == 4) {
                list.store_header = img.response.file.name
                list.store_header_url = img.response.file.http
              } else {
                list.supplier.medical = img.response.file.name
                list.supplier.medicalurl = img.response.file.http
              }
              _this.setData({
                info: list
              })
              console.log(_this.data)
            }
          })
        }
      })

    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {
      console.log('页面隐藏')
    },
    onUnload: function() {
      console.log('页面卸载')
    },
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    onJumpPage() {
      var _this = this,
        info = _this.data.info
      if (!info.idcode_positive_url) {
        wx.showToast({
          title: '请上传身份证正面',
          icon: 'none'
        })
        return false
      }
      if (!info.idcode_other_url) {
        wx.showToast({
          title: '请上传身份证反面',
          icon: 'none'
        })
        return false
      }
      if (!info.store_header_url) {
        wx.showToast({
          title: '请上传门头',
          icon: 'none'
        })
        return false
      }
      if (!info.store_environmental_url) {
        wx.showToast({
          title: '请上传环境',
          icon: 'none'
        })
        return false
      }
      if (!info.supplier.medicalurl) {
        wx.showToast({
          title: '请上传医疗器械',
          icon: 'none'
        })
        return false
      }
      wx.showToast({
        title: '提交中',
        icon:'loading'
      })
      com.link(app.link.onSaveShopInfo + wx.getStorageSync('store') + '.st', {
        idcode_positive: info.idcode_positive,
        idcode_other: info.idcode_other,
        store_header: info.store_header,
        store_environmental: info.store_environmental,
        medical: info.supplier.medical,
        code: 'meituan',
        address: info.address,
        title:info.title
      }, function(res) {
        console.log(res)
        wx.hideToast()
        if (res.data.state) {
          wx.showModal({
            title: '温馨提示',
            content: res.data.message,
            showCancel: false,
            success(res) {
              if (res.confirm) {
                if (_this.data.upData) {
                  wx.reLaunch({
                    url: '/pages/onCooperation/onCooperation',
                  })
                } else {
                  wx.navigateTo({
                    url: '/pages/onOrderBegin/onOrderBegin',
                  })
                }
              }
            }
          })
        } else {
          wx.showModal({
            title: '温馨提示',
            content: res.data.message,
          })
        }
      })
    }
  })